package config

import (
	"FlowMaster/model"
	"fmt"

	"gopkg.in/ini.v1"
)

func InitConfig() (model.Config, error) {

	cfg, err := ini.Load("config.ini")
	if err != nil {
		fmt.Println("Error loading config:", err)
		return model.Config{}, err
	}

	c := model.Config{}
	cfg.MapTo(&c)

	return c, nil
}

func LoadCustCount() (model.CustCount, error) {
	c, _ := InitConfig()
	return c.CustCount, nil
}

func LoadDataBase() (model.DataBase, error) {
	c, _ := InitConfig()
	return c.DataBase, nil
}

func LoadYunyouqilu() (model.Yunyouqilu, error) {
	c, _ := InitConfig()
	return c.Yunyouqilu, nil
}

func LoadInterval() (model.Interval, error) {
	c, _ := InitConfig()
	return c.Interval, nil
}

func LoadLog() (model.Log, error) {
	c, _ := InitConfig()
	return c.Log, nil
}

func LoadPFlib() (model.PFlib, error) {
	c, _ := InitConfig()
	return c.PFlib, nil
}

func LoadActive() (model.Active, error) {
	c, _ := InitConfig()
	return c.Active, nil
}

func LoadCoefficient() (model.Coefficient, error) {
	c, _ := InitConfig()
	return c.Coefficient, nil
}
